//
//  AllFavTableViewCell.m
//  Rail
//
//  Created by huyuchen on 2018/3/21.
//  Copyright © 2018年 Hychen. All rights reserved.
//

#import "AllFavTableViewCell.h"

@interface AllFavTableViewCell ()
@property (weak, nonatomic) IBOutlet UIImageView *iconView;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *statusLabel;

@end
@implementation AllFavTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.statusLabel.textColor = Color_RGB(71, 220, 150);
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setModel:(AllFavModel *)model {
    _model = model;
    self.statusLabel.textColor = Color_RGB(71, 220, 150);
    switch (model.fav_type) {
        case FavTypeLine:
        {
            self.iconView.image = ImageNamed_bb(@"app_collect_circuit_ic");
            self.titleLabel.text = model.line_name;
            switch (model.line_status) {
                case LineWorkingStatusTodo:
                    self.statusLabel.textColor = Color_LineTodo;
                    break;
                case LineWorkingStatusFinish:
                    self.statusLabel.textColor = Color_LineFinish;
                    break;
                case LineWorkingStatusWorking:
                    self.statusLabel.textColor = Color_LineWorking;
                    break;
                default:
                    break;
            }
            self.statusLabel.text = [WarnLevelConfig lineWorkStatusString:model.line_status];
        }
            break;
        case FavTypeDevice:
        {
            self.iconView.image = ImageNamed_bb(@"app_collect_facility_ic");
            self.titleLabel.text = model.device_name;
            self.statusLabel.textColor = model.device_status == DeviceStatusOnline ? RGB(65, 206, 231) : RGB(154, 154, 154);
            self.statusLabel.text = [WarnLevelConfig deviceStatusString:model.device_status];
        }
            break;
        case FavTypeWorkArea:
        {
            self.iconView.image = ImageNamed_bb(@"app_collect_check_box_n");
            self.titleLabel.text = model.area_name;
            self.statusLabel.text = @"";
        }
        default:
            break;
    }
}

- (void)setLineModel:(LineFavModel *)lineModel {
    _lineModel = lineModel;
    self.titleLabel.text = lineModel.line_name;
    self.iconView.image = ImageNamed_bb(@"app_collect_circuit_ic");
    self.statusLabel.text = [WarnLevelConfig lineWorkStatusString:lineModel.status];
    switch (lineModel.status) {
        case LineWorkingStatusTodo:
            self.statusLabel.textColor = Color_LineTodo;
            break;
        case LineWorkingStatusFinish:
            self.statusLabel.textColor = Color_LineFinish;
            break;
        case LineWorkingStatusWorking:
            self.statusLabel.textColor = Color_LineWorking;
            break;
        default:
            break;
    }
}

- (void)layoutSubviews {
    [super layoutSubviews];
    float indentPoints = self.indentationLevel * self.indentationWidth;
    self.contentView.frame = CGRectMake(
                                        indentPoints,
                                        self.contentView.frame.origin.y,
                                        self.contentView.frame.size.width - indentPoints,
                                        self.contentView.frame.size.height
                                        );
}

@end
